package com.mabs.ground.core.user.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

import com.mabs.ground.core.model.ModelObject;
import com.mabs.ground.shared.UserBean;

/**
 * 
 * @author <a href="Email: mohamedarbi.benslimane@allence-tunisie.com">Ben
 *         Slimane Arbi</a>
 * @version 1.0
 * @since 1.0 - 25 juil. 2014 - 20:23:21
 */
@XmlRootElement
@Entity
@Table(name = "user", catalog = "interaction", uniqueConstraints = @UniqueConstraint(columnNames = "user_username"))
public class User extends ModelObject implements UserBean, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8356687264286129112L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "user_id", unique = true, nullable = false)
	private Long userId;

	@NotNull
	@Column(name = "user_username", unique = true)
	private String userUsername;

	@NotNull
	@Size(max = 100)
	@Column(name = "user_password")
	private String userPassword;

	@NotNull
	@Size(max = 100)
	@Column(name = "user_real_name")
	private String userRealName;

	@NotNull
	@Size(max = 50)
	@Column(name = "user_email")
	private String userEmail;

	@NotNull
	// @Enumerated(EnumType.STRING)
	@Column(name = "user_role")
	private String userRole;

	@NotNull
	@Column(name = "user_connection_satus")
	private Boolean userConnectionStatus;

	@NotNull
	@Column(name = "user_activation_status")
	private Boolean userActivationStatus;

	@NotNull
	@Temporal(TemporalType.DATE)
	@Column(name = "user_creation_date")
	private Date userCreationDate;

	@NotNull
	@Temporal(TemporalType.DATE)
	@Column(name = "user_modification_date")
	private Date userModificationDate;

	@Temporal(TemporalType.DATE)
	@Column(name = "user_deleting_date")
	private Date userDeletingDate;

	public User() {
	}

	public Long getUserId() {
		return this.userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUserUsername() {
		return this.userUsername;
	}

	public void setUserUsername(String userUsername) {
		this.userUsername = userUsername;
	}

	public String getUserPassword() {
		return this.userPassword;
	}

	public Boolean isUserConnectionStatus() {
		return this.userConnectionStatus;
	}

	public void setUserConnectionStatus(Boolean userConnectionSatus) {
		this.userConnectionStatus = userConnectionSatus;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getUserRole() {
		return this.userRole;
	}

	public void setUserRole(String role) {
		this.userRole = role;
	}

	public String getUserRealName() {
		return this.userRealName;
	}

	public void setUserRealName(String userRealName) {
		this.userRealName = userRealName;
	}

	public String getUserEmail() {
		return this.userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public Boolean isUserActivationStatus() {
		return this.userActivationStatus;
	}

	public void setUserActivationStatus(Boolean userActivationStatus) {
		this.userActivationStatus = userActivationStatus;
	}

	public Date getUserCreationDate() {
		return this.userCreationDate;
	}

	public void setUserCreationDate(Date userCreationDate) {
		this.userCreationDate = userCreationDate;
	}

	public Date getUserModificationDate() {
		return this.userModificationDate;
	}

	public void setUserModificationDate(Date userModificationDate) {
		this.userModificationDate = userModificationDate;
	}

	public Date getUserDeletingDate() {
		return this.userDeletingDate;
	}

	public void setUserDeletingDate(Date userDeletingDate) {
		this.userDeletingDate = userDeletingDate;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj != null && obj instanceof User) {
			User user = (User) obj;
			return getUserId() == user.getUserId();
		}
		return false;
	}

	@Override
	public Serializable getId() {
		return userId;
	}

}
